#include "base_entity.h"
#include "base_scene.h"

USING_NS_CC;

void BaseEntity::addToScene(BaseScene *scene)
{
    if ( scene && scene != this->scene )
    {
        removeFromScene();
        CC_SAFE_RELEASE(this->scene);
        CC_SAFE_RETAIN(scene);
        scene->addEntity(this);
        this->scene = scene;
    }
}

void BaseEntity::removeFromScene()
{
    if ( this->scene )
    {
        this->scene->removeEntity(this);
        CC_SAFE_RELEASE_NULL(this->scene);
    }
}